import {Input, Button, message} from "antd";
import {LockOutlined, MailOutlined} from '@ant-design/icons';
import styles from './style.module.scss'
import $http from '@/api/index'
import {useState} from "react";

function Login() {
    const [messageApi, contextHolder] = message.useMessage();
    const submit = () => {
        $http.login(form).then(res => {
            if (res != null) {
                messageApi.success('登录成功');
            }
        })
    }
    const [form, setForm] = useState({
        email: '',
        password: ''
    })
    return (
        <div>
            {contextHolder}
            <Input onChange={(e) => {
                setForm({...form, email: e.target.value})
            }} size="large" placeholder="请输入邮箱" prefix={<MailOutlined/>}/>
            <Input.Password onChange={(e) => {
                setForm({...form, password: e.target.value})
            }} style={{marginTop: '15px'}} size="large" placeholder="请输入密码" prefix={<LockOutlined/>}/>
            <Button onClick={submit} type="primary" className={styles.loginBtn} block>立即登录</Button>
        </div>
    )
}

export default Login